import java.util.Stack;

/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-05-11
 * Time:17:49
 */
public class 用两个栈实现队列 {
    class CQueue {
        private Stack<Integer> stack1;
        private Stack<Integer> stack2;

        public CQueue() {
            stack1 = new Stack<>();
            stack2 = new Stack<>();
        }

        public void appendTail(int value) {
            stack1.push(value);
        }

        public int deleteHead() {
            if(stack2.isEmpty()) {
                if(stack1.isEmpty()){
                    return -1;
                }
                while(!stack1.isEmpty()) {
                    stack2.push(stack1.pop());
                }
            }
            return stack2.pop();
        }


    }
}
